<script src="/admin/state"></script>
<script>
  if (isState) {
  } else {
    location.href = 'login.html'
  }
</script>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="utf-8">
  <title></title>
  <link rel="stylesheet" href="../assets/vendors/editor.md/css/editormd.css">
  <link rel="stylesheet" href="../assets/vendors/bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="../assets/vendors/font-awesome/css/font-awesome.css">
  <link rel="stylesheet" href="../assets/vendors/nprogress/nprogress.css">
  <link rel="stylesheet" href="../assets/css/admin.css">
  <script src="../assets/vendors/nprogress/nprogress.js"></script>
  <script src="../assets/vendors/jquery/jquery.js"></script>
  <script src="../assets/vendors/editor.md/editormd.min.js"></script>
</head>

<body>
  <script>NProgress.start()</script>

  <div class="main">
    <nav class="navbar">
      <button class="btn btn-default navbar-btn fa fa-bars"></button>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="password-reset.html"><i class="fa fa-user"></i>修改资料</a></li>
        <li><a href="javascript:;" class="loginout"><i class="fa fa-sign-out"></i>退出</a></li>
      </ul>
    </nav>
    <div class="container-fluid">
      <div class="page-title">
        <h1>写文章</h1>
      </div>
      <!-- 有错误信息时展示 -->
      <!-- <div class="alert alert-danger">
        <strong>错误！</strong>发生XXX错误
      </div> -->
      <div id="parentBox">
        <form class="row" id="addForm">
          <div class="col-md-12">
            <div class="form-group">
              <label for="title">标题</label>
              <input id="title" name="title" class="form-control input-lg" type="text" placeholder="文章标题">
            </div>
            <div class="form-group">
              <label for="">内容</label>
              <div id="content">
                <!-- Tips: Editor.md can auto append a `<textarea>` tag -->
                <textarea style="display:none;"></textarea>
              </div>
            </div>
          </div>
          <div class="col-md-3">
            <div class="form-group">
              <label for="category">所属分类</label>
              <select id="category" class="form-control" name="class">

              </select>
            </div>
            <div class="form-group">
              <label for="author">作者</label>
              <input id="author" name="author" class="form-control" type="text">
            </div>
            <div class="form-group">
              <button class="btn btn-primary" id="btnPost" type="submit">保存</button>
            </div>
          </div>
        </form>
      </div>
      <!-- <form id="upload" class="row">
        <div class="col-md-4">
          <label class="title">上传文件</label>
          <input type="file" name="upload" id="file">
          <img id="upload_img" src="" alt=""> <br>
          <button type="submit" class="btn btn-primary">确定</button><br>
        </div>
        <div class="col-md-8">
          <div class="url">
            <label>图片链接: <span class="text"></span> <a onclick="urlcopy()" href="javascript:;"
                class="copy">复制</a></label>
            <input type="text" value="" style="opacity: 0;">
          </div>
        </div>
      </form> -->
    </div>
  </div>

  <div class="aside">
    <div class="profile">
      <img class="avatar" src="../uploads/avatar.jpg">
      <h3 class="name"></h3>
    </div>
    <ul class="nav">
      <li>
        <a href="index.html"><i class="fa fa-dashboard"></i>仪表盘</a>
      </li>
      <li class="active">
        <a href="#menu-posts" data-toggle="collapse">
          <i class="fa fa-thumb-tack"></i>文章<i class="fa fa-angle-right"></i>
        </a>
        <ul id="menu-posts" class="collapse in">
          <li><a href="posts.html">所有文章</a></li>
          <li class="active"><a href="post-add.html">写文章</a></li>
          <li><a href="categories.html">分类目录</a></li>
        </ul>
      </li>
      <li>
        <a href="comments.html"><i class="fa fa-comments"></i>评论</a>
      </li>
      <li>
        <a href="#menu-settings" class="collapsed" data-toggle="collapse">
          <i class="fa fa-cogs"></i>设置<i class="fa fa-angle-right"></i>
        </a>
        <ul id="menu-settings" class="collapse">
          <li><a href="nav.html">导航栏设置</a></li>
          <li><a href="link.html">友情链接设置</a></li>
          <li><a href="settings.html">网站设置</a></li>
        </ul>
      </li>
    </ul>
  </div>

  <script src="../assets/vendors/bootstrap/js/bootstrap.js"></script>
  <!-- <script src="../assets/vendors/wangEditor/wangEditor.min.js"></script> -->
  <script src="../assets/vendors/art-template/template-web.js"></script>
  <script src="js/ajax.js"></script>
  <script src="js/common.js"></script>
  <script src="js/post_add.js"></script>
  <script type="text/html" id="categoryTpl">
    {{each categories}}
    <option value="{{$value.name}}" class="category">{{$value.name}}</option>
    {{/each}}
  </script>

  <script>
    // var E = window.wangEditor;
    // var editor = new E("#content");
    // editor.config.showFullScreen = true;
    // editor.create();
    $(function () {
      var editor = editormd("content", {
        width: "100%",
        height: "500px",
        // markdown: "xxxx",     // dynamic set Markdown text
        path: "../assets/vendors/editor.md/lib/",  // Autoload modules mode, codemirror, marked... dependents libs path
        htmlDecode: "style,script,iframe|on*",  //开启html解析
        tex: true,  // 默认不解析
        flowChart: true,  // 默认不解析
        sequenceDiagram: true,  // 默认不解析
        // 图片上传
        saveHTMLToTextarea: true,//这个配置，方便post提交表单
        imageUpload: true,
        imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
        imageUploadURL: "/upload",
        tex: true,                   // 开启科学公式TeX语言支持，默认关闭
        flowChart: true,             // 开启流程图支持，默认关闭
        sequenceDiagram: true,
        emoji: true

      });
    });

  </script>
  <script>
    $.ajax({
      url: '/admin/webset',
      success: function (reslut) {
        var res = reslut
        $('title').html(res.name + '-' + '文章管理')
      }
    })
    // 作者的名称 从本地获取 因为成功的时候 已经存储到本地了
    $('.name').html(localStorage.getItem("uname"))
  </script>

  <script>NProgress.done()</script>
</body>

</html>